﻿using Google.Protobuf.WellKnownTypes;
using JsonModel;
using MyBot.Models;
using MyBot.Models.MessageModels;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RgChannelBot
{
    public static class Extensions
    {
        public static Color GetColor(string name)
        {
            switch (name)
            {
                case "pink":
                    return System.Drawing.Color.FromArgb(255, 150, 222);

                case "red":
                    return System.Drawing.Color.FromArgb(197, 0, 0);

                case "brown":
                    return System.Drawing.Color.FromArgb(148, 71, 16);

                case "silver":
                    return System.Drawing.Color.FromArgb(160, 160, 160);

                case "light_green":
                    return System.Drawing.Color.FromArgb(50, 205, 50);

                case "crimson":
                    return System.Drawing.Color.FromArgb(220, 20, 60);

                case "cyan":
                    return System.Drawing.Color.FromArgb(0, 183, 235);

                case "aqua":
                    return System.Drawing.Color.FromArgb(0, 255, 255);

                case "deep_pink":
                    return System.Drawing.Color.FromArgb(255, 20, 147);

                case "tomato":
                    return System.Drawing.Color.FromArgb(255, 100, 72);

                case "yellow":
                    return System.Drawing.Color.FromArgb(250, 255, 134);

                case "magenta":
                    return System.Drawing.Color.FromArgb(255, 0, 144);

                case "blue_green":
                    return System.Drawing.Color.FromArgb(77, 255, 184);

                case "orange":
                    return System.Drawing.Color.FromArgb(255, 153, 102);

                case "lime":
                    return System.Drawing.Color.FromArgb(191, 255, 0);

                case "green":
                    return System.Drawing.Color.FromArgb(34, 139, 34);

                case "emerald":
                    return System.Drawing.Color.FromArgb(80, 200, 120);

                case "carmine":
                    return System.Drawing.Color.FromArgb(150, 0, 24);

                case "nickel":
                    return System.Drawing.Color.FromArgb(114, 116, 114);

                case "mint":
                    return System.Drawing.Color.FromArgb(152, 251, 152);

                case "army_green":
                    return System.Drawing.Color.FromArgb(75, 83, 32);

                case "pumpkin":
                    return System.Drawing.Color.FromArgb(238, 118, 0);

                default:
                    return System.Drawing.Color.FromArgb(255, 255, 255);
            }
        }

        public static string FormatTime(int minutes)
        {
            TimeSpan ts = new(0, minutes, 0);
            string time = "";
            if (ts.Days >= 365)
            {
                int year = (int)Math.Floor((decimal)ts.Days / 365);
                time += year + "年";
                ts -= new TimeSpan(8766 * year, 0, 0);
            }
            if (ts.Days >= 30)
            {
                int month = (int)Math.Floor((decimal)ts.Days / 30);
                time += month + "月";
                ts -= new TimeSpan(720 * month, 0, 0);
            }
            if (ts.Days > 0)
                time += $"{ts.Days}天";
            if (ts.Hours > 0)
                time += $"{ts.Hours}小时";
            time += $"{ts.Minutes}分钟";
            return time;
        }
    }
}